﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using HSE.Common;
using System.IO;

namespace HSE
{
    public partial class AqxsAdd : UserControl
    {
        private OpenFileDialog _openfileDialog1;
        ObservableCollection<PhotoInfo> collection;
        public AqxsAdd()
        {
            InitializeComponent();
        }

        private void RadButton_Click(object sender, RoutedEventArgs e)
        {
            _openfileDialog1 = new OpenFileDialog();
            collection = new ObservableCollection<PhotoInfo>();
            // Set filter options and filter index.
            _openfileDialog1.Filter = "Image Files (*.jpg;*.jpeg;*.png)|*.jpg;*.jpeg;*.png";
            _openfileDialog1.FilterIndex = 1;
            _openfileDialog1.Multiselect = true;

            if (_openfileDialog1.ShowDialog() == true)
            {
                foreach (FileInfo info in _openfileDialog1.Files)
                {
                    FileStream stream = info.OpenRead();

                    PhotoInfo photo = new PhotoInfo();
                    photo.IconContent = Util.ReadFile(stream);
                    collection.Add(photo);
                }

                lst.ItemsSource = collection;
            }
        }

        private void Image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Image img = sender as Image;
            collection.Remove(img.DataContext as PhotoInfo);
        }

        void aaa()
        {
            //HttpWebRequest post = (HttpWebRequest)WebRequest.Create(endpoint);
            //post.PostData("http://localhost:13936/GetData.aspx", "id=cnblogs.com/rhythmk", currentContext, new SendOrPostCallback(ShowResult));
        }
    }
}
